
<?php $selected = 0 ?>
<!--BLOC01-->

<div class="number">
    <img src="<?php echo $this->baseUrl('img/01.png'); ?>" />
</div>

<form method='post' action='<?php echo $this->baseUrl('index/reservation'); ?>'>
    <div class="block">
        <h2>Pré-réservation : à quelle représentation souhaitez-vous assister ?</h2>
        <p class="note"><span class="pink">Note</span> : votre pré-réservation n’est pas définitive. Vous pourrez revenir sur le site pour la modifier.</p>

        <?php foreach ($this->representations as $representation): ?>
            
            <div class="representation"> 

                <img src="<?php echo $this->baseUrl('img/xs_' . $representation['spectacle_pathimg']); ?>"  alt="<?php echo $representation['spectacle_nom'] ?>" width="133px" />
                <h3>
                    <?php echo $representation['spectacle_nom'] ?> <br /> 
                    <span class="date"><?php echo strftime("%A %d %B - %H:%M", strtotime($representation['representation_date'] . " " . $representation['representation_time'])) ?></span><br />
                    <a target="_blank"class="lieu"  href="<?php echo $representation['lien_gmap'] ?>"><?php echo $representation['lieu_name'] ?> </a>
                </h3>

                <?php $seat_available = min($representation['seat_maxavailable'] - $representation['seat_reserved'],10) ?>
                
                <?php if ($seat_available < 1) : ?>
                    Plus de place.        
                <?php else: ?>
                    <select name="resa[<?php echo $representation['id_spectacle_has_representation'] ?>]">
                        <?php for ($i = 0; $i <= $seat_available; $i++): ?>
                            <option value="<?php echo $i ?>" <?php if ($i == $selected): ?> SELECTED <?php endif ?>><?php echo $i ?> place<?php if ($i > 1) echo 's' ?></option>
                        <?php endfor ?>
                    </select>
                <?php endif ?>



            </div>
        <?php endforeach ?>

        <!--fin DIV BLOCK-->
    </div>
    <!--BLOC02-->

    <div class="number2">
        <img src="<?php echo $this->baseUrl('img/02.png'); ?>" />
    </div>

    <div class="block2">

        <h2>Pré-réservation : finalisez votre pré-réservation en saisissant nom, prénom et email.</h2>

        <p class="note"><span class="pink">Note</span> : souvenez-vous de l’email utilisé, il vous servira pour modifier votre pré-réservation le cas échéant.</p>

        <label for=""><span class="form">Votre prénom: </span></label>
        <input class="resa" type="text" name="prenom" <?php if (isset($this->isModify)): ?>READONLY <?php endif ?> 
               <?php if (isset($this->data['prenom']['value'])): ?>  value='<?php echo $this->data['prenom']['value'] ?>'<?php endif ?>/>
               <?php if (isset($this->data['prenom']['errors'])): ?>
                   <?php foreach ($this->data['prenom']['errors'] as $error): ?>
                <span class='formError'><?php echo $error ?></span>
            <?php endforeach ?>
        <?php endif ?>
        <br />


        <label for=""><span class="form">Votre nom: </span></label>
        <input class="resa" type="text" name="nom"    <?php if (isset($this->isModify)): ?>READONLY <?php endif ?> 
               <?php if (isset($this->data['nom']['value'])): ?>  value='<?php echo $this->data['nom']['value'] ?>'<?php endif ?>/>

               <?php if (isset($this->data['nom']['errors'])): ?>
                   <?php foreach ($this->data['nom']['errors'] as $error): ?>
                       <span class='formError'><?php echo $error ?></span>
                   <?php endforeach ?>
               <?php endif ?>
        <br />

        <label for=""><span class="form">Votre email: </span></label>
        <input class="resa" type="text" name="email"  <?php if (isset($this->isModify)): ?>READONLY <?php endif ?> 
               <?php if (isset($this->data['email']['value'])): ?>  value='<?php echo $this->data['email']['value'] ?>'<?php endif ?>/>
               <?php if (isset($this->data['email']['errors'])): ?>
                   <?php foreach ($this->data['email']['errors'] as $error): ?>
                <span class='formError'><?php echo $error ?></span>
            <?php endforeach ?>
        <?php endif ?>
        <br />

        <!--fin DIV BLOCK2-->
    </div>
    <input type="hidden" value="0" name="modify" >

    <input class="action" type='submit' style="background:url(<?php echo $this->baseUrl('img/enregistrer.png'); ?>) no-repeat; border:none; width:350px; height:40px" value="" />
</form>

<?php

/**
 *        
        $this->view->rowCount = $rowCount;
        $this->view->representations = $representations;
 * 
 array
  0 => 
    array
      'id_spectacle_has_representation' => string '5' (length=1)
      'id_spectacle' => string '3' (length=1)
      'id_lieu' => string '1' (length=1)
      'representation_date' => string '2012-05-12' (length=10)
      'representation_time' => string '18:00:00' (length=8)
      'spectacle_nom' => string 'Salon d'été' (length=11)
      'spectacle_descriptif' => string 'spectacle annie, pascal, guillaume, camille' (length=43)
      'spectacle_pathimg' => string 'salon.jpg' (length=9)
      'lieu_name' => string 'La loge' (length=7)
      'lieu_adress' => string '77 rue de Charonne' (length=18)
      'lien_gmap' => string 'http://www.google.fr/maps?q=Th%C3%A9%C3%A2tre+de+la+loge,+77+rue+de+charonne,+75011+paris&hl=fr&ie=UTF8&ll=48.854085,2.381544&spn=0.008302,0.01929&view=map&cid=11686925685267851428&t=m&z=16&iwloc=A' (length=197)
      'seat_maxavailable' => string '80' (length=2)
      'seat_reserved' => string '1' (length=1) 
 */